package com.hjy.elasticsearch.myEnum;

/**
 * @CopyRight: 版权所有
 * @Author: hejinyi
 * @Description:
 * @Date: 2020/12/2
 */
public enum ProductTypeEnum {

    TICKET_PRODUCT(1001 , "门票"),
    HOME_PRODUCT(1002 , "房型"),
    FOOD_PRODUCT(1003 , "美食"),
    SPECIALTY_PRODUCT(1004 , "特产"),
    LINE_PRODUCT(1005 , "旅游线路"),

    SCENICSPOT_SUBJECT(1 , "景区"),
    HOTEL_SUBJECT(2 , "酒店"),
    RESTAURANT_SUBJECT(3 , "餐馆"),
    ;


    private Integer code;
    private String desc;

    private ProductTypeEnum (Integer code,String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }
    public String getDesc() {
        return desc;
    }

    public static ProductTypeEnum getEnumByNumber(Integer code){
        if (code == null){
            return null;
        }
        for (ProductTypeEnum tSORNOTEnum : ProductTypeEnum.values()) {
            if (tSORNOTEnum.getCode().equals(code)){
                return tSORNOTEnum;
            }
        }
        return null;
    }

    public static ProductTypeEnum getEnumByDesc(String desc){
        if (desc == null){
            return null;
        }
        for (ProductTypeEnum tSORNOTEnum : ProductTypeEnum.values()) {
            if (tSORNOTEnum.getDesc().equals(desc)){
                return tSORNOTEnum;
            }
        }
        return null;
    }
}
